
<script type="text/javascript">

$(function() {
  
	$( "#tab<?php echo $parent->id ?>" ).tabs();
	
})
</script>
				<div id="tab<?php echo $parent->id ?>" class="tab box">
					<ul>
						<?php foreach($categories as $key => $category): ?>
						<li><a href="#tabs-<?php echo ++$key ?>"><?php echo $category->name ?></a></li>
						<?php endforeach; ?>
					</ul>
					<h1 style="background-color:#<?php echo $parent->color ?>">
						<img src="uploads/icon/head/<?php echo $parent->image ?>" />
						<span><?php echo $parent->name ?></span>
						<a class="more" href="contents/index/<?php echo $parent->id ?>">ดูทั้งหมด</a>
						<div class="corner_left"></div>
						<div class="corner_right"></div>
					</h1>
					<div class="tab_content">
					<?php foreach($categories as $key => $category): ?>
					<div id="tabs-<?php echo ++$key ?>">
					<ul>
					<?php
					$group[18] = '18,154,122';
					$group[19] = '19,123,155,220';
					$group[20] = '20,156,125';
					$group[21] = '21,157,127,228';
					$group[22] = '22,158';
					$group[23] = '23,159,332';
					
					$group[300] = '300,154,155,156,157,158,159,160';
					$group[301] = '301,220,221,222,224,226,228,229,230';
					$group[302] = '302,122,123,124,125,127,128,129,130,332';
					
					if(!empty($group[$category->id]))
					{
						$contents = new Content;
						$contents
						->where("start_date <= date(sysdate()) and (end_date >= date(sysdate()) or end_date = date('0000-00-00')) and status = 'approve'")
						->where('category_id in ('.$group[$category->id].')')
						->limit(4)
						->order_by('id','desc')
						->get();
					}
					else
					{
						$contents = $category
						->content
						->where("start_date <= date(sysdate()) and (end_date >= date(sysdate()) or end_date = date('0000-00-00')) and status = 'approve'")
						->limit(4)
						->order_by('id','desc')
						->get();
					}
					?>
					<?php foreach($contents as $key=>$content): ?>
						<li>
							<?php if($content->url): ?>
                			<a target="_blank" href="<?php echo $content->url ?>">
							<?php else: ?>
							<a href="contents/view/<?php echo $content->id ?>">
							<?php endif; ?>
								<img src="uploads/content/thumbnail/<?php echo $content->image ?>" />
								<h2><?php echo $content->title ?></h2>
								
								<p><?php echo $content->intro ?></p>
							</a>
								<?php if(is_file('uploads/content/download/'.$content->file)): ?>
								<a href="contents/download/<?php echo $content->id ?>">
								<div class="download">
									<label>ลักษณะหนังสือ :</label><span><?php echo $content->book_type->name ?></span><img src="themes/bie/images/btn_download.gif" />
								</div>
								</a>
								<?php endif ?>
							
						</li>
						<?php echo ($key%2==1)?'<div class="clear"></div>':'' ?>
    				<?php endforeach; ?>
    				<div class="clear"></div>
					</ul>
					</div>
					<?php endforeach; ?>
						
						
					</div>
				</div>